﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BBPA.Admin.SYS.Orders.Buying
{
    public partial class List : ListPage
    {
        BLL.V_Orders bllList = new BLL.V_Orders();
        BLL.Orders bll = new BLL.Orders();
        //
        BLL.Orders_Goods bllOrders_Goods = new BLL.Orders_Goods();
        BLL.Goods bllGoods = new BLL.Goods();
        BLL.Orders_State_Log bllOrders_State_Log = new BLL.Orders_State_Log();
        BLL.Supplier bllSupplier = new BLL.Supplier();
        BLL.Account_Change_Log bllAccount_Change_Log = new BLL.Account_Change_Log();
        //
        protected string IsDelivery = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            IsDelivery = DataTypePlus.requestString(Request.QueryString["IsDelivery"]);
            if (IsDelivery == "")
            {
                switch (Security.GetCurrentUserType())
                {
                    case EnumHelper.UserType.Buyer:
                        IsDelivery = "0";
                        break;
                    case EnumHelper.UserType.Receiver:
                        IsDelivery = "1";
                        break;
                    default:
                        IsDelivery = "";
                        break;
                }
            }
            
            string sql_IsDelivery = "select OrdersID from V_Orders_Goods where IsDelivery=" + IsDelivery;
            if (IsDelivery != "")
            {
                //if (IsDelivery == "0") sql_IsDelivery += " and HasPay=0";
                //if (IsDelivery == "1") sql_IsDelivery += " and HasPay_Delivery=0";
            }
            //
            Master.show_btn_add = Master.show_btn_bat_del = Master.show_info = Master.show_edit = false;
            Master.show_formControls = true;
            if (IsDelivery != "")
            {
                Master.BasicSQL = " State=" + (int)EnumHelper.OrdersState.Buying;
                //if (IsDelivery == "1") Master.BasicSQL = " State=" + (int)EnumHelper.OrdersState.GetMoney;
                Master.BasicSQL += " and id  in(" + sql_IsDelivery + ")";
                if (IsDelivery == "0") Master.BasicSQL += " and HasPay=0";
                if (IsDelivery == "1") Master.BasicSQL += " and HasPay_Delivery=0";

            }
            else
                Master.BasicSQL = " State=" + (int)EnumHelper.OrdersState.Buying;
        }
        public override void buildSQL_Page_List_search() { }
        public override DataSet get_Page_DataSet(string sql_, string orderby_, int pageFrom_, int pageTo_) { return bllList.GetListByPage(sql_, orderby_, pageFrom_, pageTo_); }


    }
}